import { createRouter, createWebHashHistory } from 'vue-router'
import PlanetIndex from '../views/PlanetIndex.vue'
import {isLogin} from '@/utils/commDataFun'

const routes = [
    { path: '/',name: 'FreePlanetIndex', component: () => import('../components/article/FreePlanetIndex.vue') },
    { path: '/comment',name: 'PlanetComments', component: () => import('../components/sonComponent/PlanetComments') },
    { path: '/planetAdmin', name: 'PlanetIndex',component: PlanetIndex ,
        redirect: '/loopPic',
        children:[      
            { path: '/test',name: 'Test', component: () => import('../components/Test.vue') },
            { path: '/loopPic',name: 'SysIndexLoop', component: () => import('../components/system/SysIndexLoop.vue') },
            { path: '/addArticle',name: 'AddArticle', component: () => import('../components/article/AddArticle.vue') },
            { path: '/artTypeManage',name: 'ArtTypeManage', component: () => import('../components/article/ArtTypeManage.vue') },
            { path: '/memberServe',name: 'PlanetMemberServe', component: () => import('../components/article/PlanetMemberServe.vue') },
            
            // 用户路由
            { path: '/updateSelfInfo',name: 'UserInfoManage', component: () => import('../components/user/UserInfoManage.vue') },
            { path: '/userArtList',name: 'UserArtManage', component: () => import('../components/user/UserArtManage.vue') },
            { path: '/myMember',name: 'MyMember', component: () => import('../components/user/MyMember.vue') },
            { path: '/makeResume',name: 'MakeResume', component: () => import('../components/user/MakeResume.vue') },
            { path: '/myResume',name: 'MyResume', component: () => import('../components/user/MyResume.vue') },
            // 简历
            { path: '/simpleResumeFrame',name: 'SimpleResumeFrame', component: () => import('../components/user/SimpleResumeFrame.vue') },
            { path: '/resumeLibrary',name: 'ResumeLibrary', component: () => import('../components/user/ResumeLibrary.vue') },

            // 菜单
            { path: '/addMenu',name: 'AddMenu', component: () => import('../components/system/AddMenu.vue') },
            { path: '/sysDistributionManage',name: 'DistributionMenu', component: () => import('../components/system/SysDistributionManage.vue') },
            { path: '/sysRoleManage',name: 'SysRoleManage', component: () => import('../components/system/SysRoleManage.vue') },
            { path: '/menuManage',name: 'MenuManage', component: () => import('../components/system/MenuManage.vue') },
            { path: '/sysMessageHandler',name: 'SysMessageHandler', component: () => import('../components/system/SysMessageHandler.vue') },
            //灰度维护
            { path: '/grayFlow',name: 'SysGrayFlow', component: () => import('../components/system/SysGrayFlow.vue') },
            { path: '/grayReqHeader',name: 'SysGrayReqHeader', component: () => import('../components/system/SysGrayReqHeader.vue') },

            { path: '/replacePPTContent',name: 'PPTOperate', component: () => import('../components/comm/PPTOperate.vue') },

            // 网关配置
            { path: '/gatewayRouteConfig',name: 'GatewayRouteConfig', component: () => import('../components/system/GatewayRouteConfig.vue') },
            { path: '/gatewayAllowPathConfig',name: 'GatewayAllowPathConfig', component: () => import('../components/system/GatewayAllowPathConfig.vue') },
            { path: '/globalDictConfig',name: 'GlobalDictConfig', component: () => import('../components/system/GlobalDictConfig.vue') },


            // 统计
            { path: '/largeMonitoringScreen',name: 'LargeMonitoringScreen', component: () => import('../components/statistic/LargeMonitoringScreen.vue') },

            
        ]
    },
    { path: '/index',name: 'IndexHome', component: () => import('../components/IndexHome.vue') },
    { path: '/userLogin',name: 'PlanetLoginRegister', component: () => import('../components/PlanetLoginRegister.vue') },
    { path: '/loginIndexNew',name: 'LoginIndexNew', component: () => import('../views/LoginIndexNew.vue') },
    { path: '/memberCom',name: 'MemberCom', component: () => import('../components/sonComponent/MemberCom.vue') },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

//路由守卫
// router.beforeEach((to, from, next) => {
//     if(to.name === 'FreePlanetIndex' || to.name === 'PlanetLoginRegister'){
//         next()
//     }else{
//         if(isLogin()){
//             next()
//         }else{
//             next({name: 'PlanetLoginRegister'})
//         }
//     }
// })

export default router
